#include "print.h"
#include "init.h"
#include "thread.h"
#include "interrupt.h"
#include "keyboard.h"
#include "console.h"
#include "ioq.h"


void k_thread_a(void*);
void k_thread_b(void*);

int main() {
    my_set_cursor(160);
    put_str("I am kernel\n");
    init_all();

    // thread_start("k_thread_b", 16, k_thread_b, " A_");
    // thread_start("k_thread_b", 8 , k_thread_b, " B_");

    // intr_enable();
    while(1);

    // intr_enable();
    // while(1){ put_str("M "); }

    return 0;
}


void k_thread_a(void* arg){
    char* para = arg;
    while(1) put_str(para);
}


void k_thread_b(void* arg){
    char* para = arg;
    while(1){
        enum intr_status old_status = intr_disable();
        if(!ioq_is_empty(&kbd_buf)){
            console_put_str(para);
            char ch = ioq_get_char(&kbd_buf);
            console_put_char(ch);
        }
        intr_set_status(old_status);
    }
}
